package com.example.scrollviewdemo.slice;

import com.example.scrollviewdemo.ResourceTable;
import ohos.aafwk.ability.AbilitySlice;
import ohos.aafwk.content.Intent;
import ohos.agp.components.Image;
import ohos.agp.components.ScrollView;

public class MainAbilitySlice extends AbilitySlice {
    @Override
    public void onStart(Intent intent) {
        super.onStart(intent);
        super.setUIContent(ResourceTable.Layout_ability_main);

        ScrollView scrollView = (ScrollView) findComponentById(ResourceTable.Id_scrollview);
        scrollView.setReboundEffect(true);

        scrollView.doFling(0, 100);

        Image image = (Image) findComponentById(ResourceTable.Id_image1);
        image.setClickedListener( component -> {
            scrollView.fluentScrollBy(0, 800);
        });
        ScrollView.ReboundEffectParams params = new ScrollView.ReboundEffectParams(10, 0.1f, 20);
        scrollView.setReboundEffectParams(params);
    }

    @Override
    public void onActive() {
        super.onActive();
    }

    @Override
    public void onForeground(Intent intent) {
        super.onForeground(intent);
    }
}
